package com.hzhr.iot.device.convertor;

import com.hzhr.iot.device.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.device.model.implIotDeviceType.ImplIotDeviceTypeModel;
import com.hzhr.iot.device.entity.ImplIotDeviceTypeEntity;
import com.hzhr.iot.device.entity.ext.ImplIotDeviceTypeEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.device.model.implIotDeviceType.ImplIotDeviceTypeModel;
import com.hzhr.iot.device.model.implIotDeviceType.ImplIotDeviceTypeGetModel;
import com.hzhr.iot.device.queryModel.custom.ImplIotDeviceTypeCustomQueryModel;

@Component
public class ImplIotDeviceTypeConvertor {
    @Autowired
    AlarmDataCustomConvertor alarmDataCustomConvertor;
    @Autowired
    CollectDataCustomConvertor collectDataCustomConvertor;
    @Autowired
    CollectDeviceCustomConvertor collectDeviceCustomConvertor;
    @Autowired
    CollectDeviceTypeCustomConvertor collectDeviceTypeCustomConvertor;
    @Autowired
    DeviceInfoCardCustomConvertor deviceInfoCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardCustomConvertor deviceMaintenanceCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardItemCustomConvertor deviceMaintenanceCardItemCustomConvertor;
    @Autowired
    ImplFactoryCustomConvertor implFactoryCustomConvertor;
    @Autowired
    ImplRecordCustomConvertor implRecordCustomConvertor;
    @Autowired
    IotDeviceCustomConvertor iotDeviceCustomConvertor;
    @Autowired
    IotDeviceTypeCustomConvertor iotDeviceTypeCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;
    @Autowired
    ProdFactoryCustomConvertor prodFactoryCustomConvertor;
    @Autowired
    RegulatorCollectDataCustomConvertor regulatorCollectDataCustomConvertor;
    @Autowired
    UserCompanyCustomConvertor userCompanyCustomConvertor;

    public ImplIotDeviceTypeEntity implIotDeviceTypeModel2entity(ImplIotDeviceTypeModel in) {
        //未转换字段: 
        if (in == null) return null;
        ImplIotDeviceTypeEntity result = new ImplIotDeviceTypeEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public ImplIotDeviceTypeEntity implIotDeviceTypeModel2entity(ImplIotDeviceTypeModel in, ImplIotDeviceTypeEntity ori) {
        //未转换字段: 
        if (in == null) return null;
        ImplIotDeviceTypeEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<ImplIotDeviceTypeEntity> implIotDeviceTypeModelList2entityList(List<ImplIotDeviceTypeModel> in) {
        if (in == null) return null;
        List<ImplIotDeviceTypeEntity> result = new ArrayList<>();
        for (ImplIotDeviceTypeModel item : in) {
            result.add(implIotDeviceTypeModel2entity(item));
        }
        return result;
    }
    public ImplIotDeviceTypeModel entity2implIotDeviceTypeModel(ImplIotDeviceTypeEntity in) {
        //未转换字段: 
        if (in == null) return null;
        ImplIotDeviceTypeModel result = new ImplIotDeviceTypeModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<ImplIotDeviceTypeModel> entityList2implIotDeviceTypeModelList(List<ImplIotDeviceTypeEntity> in) {
        if (in == null) return null;
        List<ImplIotDeviceTypeModel> result = new ArrayList<>();
        for (ImplIotDeviceTypeEntity item : in) {
            result.add(entity2implIotDeviceTypeModel(item));
        }
        return result;
    }
    public ImplIotDeviceTypeModel ext2implIotDeviceTypeModel(ImplIotDeviceTypeEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        ImplIotDeviceTypeModel result = new ImplIotDeviceTypeModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        return result;
    }
    public List<ImplIotDeviceTypeModel> extList2implIotDeviceTypeModelList(List<ImplIotDeviceTypeEntityExt> in) {
        if (in == null) return null;
        List<ImplIotDeviceTypeModel> result = new ArrayList<>();
        for (ImplIotDeviceTypeEntityExt item : in) {
            result.add(ext2implIotDeviceTypeModel(item));
        }
        return result;
    }
    public ImplIotDeviceTypeGetModel extList2implIotDeviceTypeGetModel(List<ImplIotDeviceTypeEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<ImplIotDeviceTypeModel> modelList = extList2implIotDeviceTypeModelList(extList);
        if (modelList == null) {
            ImplIotDeviceTypeGetModel result = new ImplIotDeviceTypeGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (ImplIotDeviceTypeModel model : modelList) {
                model.setDes(null);
            }
        }

        ImplIotDeviceTypeGetModel result = new ImplIotDeviceTypeGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public ImplIotDeviceTypeGetModel entity2implIotDeviceTypeGetModel(ImplIotDeviceTypeEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<ImplIotDeviceTypeEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2implIotDeviceTypeGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, ImplIotDeviceTypeEntityExt.class));
        return extList2implIotDeviceTypeGetModel(extList, total, changeCount, query);
     }
    public ImplIotDeviceTypeCustomQueryModel implIotDeviceTypeService_query2queryModel(Map<String, Object> query) {
        ImplIotDeviceTypeCustomQueryModel queryModel = new ImplIotDeviceTypeCustomQueryModel();

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

